<template>
    <div class="dis-IB" v-if="val!=''">
        <span v-if="!Type" :class="{'buttonStyle':buttonStyle}" class="text-primary"
              v-clipboard:copy="val"
              v-clipboard:success="onCopy"
              v-clipboard:error="onError"
              style="cursor: pointer"
        >{{title}}</span>
        <a-icon type="copy"
                v-if="Type"
                style="cursor: pointer"
                v-clipboard:copy="val"
                v-clipboard:success="onCopy"
                v-clipboard:error="onError"
        />
    </div>
</template>

<script>
///复制
    export default {
       props:{
            title:{

            },
           val:{

           },
           Type:{
                default:false,
           },
           buttonStyle:{//按钮样式模式
                default: false,
           }
       },
        methods: {
            onCopy: function (e) {
                this.$message.success('复制成功: ' + e.text);
            },
            onError: function () {
                this.$message.error('复制失败');
            }
        }
    };
</script>

<style scoped>
    .dis-IB{
       display: inline-block;
    }
    .buttonStyle{
        display: inline-block;
        padding:8px 15px;
        background: #1990FF;
        color:#fff;
        font-size: 14px;
    }
</style>